package com.ziq.zcamp.manager

import android.os.Handler
import android.os.Looper
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData

object DataManager {
    var postingVersion = MutableLiveData<Int>()
    var postingPublishVersion = MutableLiveData<Int>()
    var followStatusVersion = MutableLiveData<Int>()

    //控制社区推荐的【+】悬浮窗是否显示
    private val postingBtShowSource = MutableLiveData<Boolean>()
    val postingBtShow : LiveData<Boolean> = postingBtShowSource

    //控制社区的主页是显示帖子还是活动Tab
    private val communityTabShowSource = MutableLiveData<Boolean>()
    //不给其他地方的代码修改value
    val communityTabShow : LiveData<Boolean> = communityTabShowSource

    val mHandler = Handler(Looper.getMainLooper())
    // 拉黑、解除拉黑、
    // 文章删除、
    // 动态删除、
    // 视频删除、
    // 登陆和退出登陆
    // 文章发布、
    // 动态发布
    // 视频发布
    fun increasePostingListVersion() {
        if(postingVersion.value == null){
            postingVersion.postValue(0)
        } else {
            postingVersion.postValue(postingVersion.value!!.plus(1))
        }
    }

    // 文章发布、
    // 动态发布
    // 视频发布
    fun increasePostingPublishVersion() {
        if(postingPublishVersion.value == null){
            postingPublishVersion.postValue(0)
        } else {
            postingPublishVersion.postValue(postingPublishVersion.value!!.plus(1))
        }
    }

    //关注、取消关注
    fun increaseFollowStatusVersion() {
        if(followStatusVersion.value == null){
            followStatusVersion.postValue(0)
        } else {
            followStatusVersion.postValue(followStatusVersion.value!!.plus(1))
        }
    }

    //控制发布悬浮窗是否显示
    fun changeCommunityPostingBtnShow(show : Boolean){
        postingBtShowSource.value = show
    }

    //社区tab跳转至帖子
    fun communityDisplayPosts(){
        communityTabShowSource.value = true
    }

    //社区tab跳转至活动
    fun communityDisplayActivity(){
        communityTabShowSource.value = false
    }

}